﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using KKCai.App.Model;
using KKCai.App.DAL.DaoImpl;

public partial class admin_type_edit : KKCai.Web.ManagerPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = GetIntUrlParam("id");
            TypeInfo info = new TypeDao().Get(id);

            if (info != null)
            {
                //txtCode.Text = info.Code;
                txtName.Text = info.Name;
                txtOrderID.Text = info.OrderID.ToString();
            }
        }
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        TypeDao dao = new TypeDao();

        int id = GetIntUrlParam("id");
        TypeInfo info = dao.Get(id);

        if (info != null)
        {
            //info.Code = txtCode.Text.Trim();
            info.Name = txtName.Text.Trim();
            info.OrderID = Convert.ToInt32(txtOrderID.Text.Trim());
            
            dao.Update(info);

            ClientScript.RegisterStartupScript(this.GetType(), "message", "<script>alert('更新成功!');</script>");
        }
    }
}
